﻿using System;
using System.Data;
using System.Collections.Generic;
using Charmmax.Model;
namespace Charmmax.BLL
{
    /// <summary>
    /// 业务逻辑类Vote_User 的摘要说明。
    /// </summary>
    public class Vote_User
    {
        private readonly Charmmax.DAL.Vote_User dal = new Charmmax.DAL.Vote_User();
        public Vote_User()
        { }
        #region  成员方法
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int U_ID)
        {
            return dal.Exists(U_ID);
        }
        /// <summary>
        /// 检查登陆
        /// </summary>
        public bool CheckLogin(Charmmax.Model.Vote_User model)
        {
            return dal.CheckLogin( model);
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Charmmax.Model.Vote_User model)
        {
            return dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Charmmax.Model.Vote_User model)
        {
            dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public void Delete(int U_ID)
        {

            dal.Delete(U_ID);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Charmmax.Model.Vote_User GetModel(int U_ID)
        {

            return dal.GetModel(U_ID);
        }

        /// <summary>
        /// 得到一个对象实体，从缓存中。
        /// </summary>
        //public Charmmax.Model.Vote_User GetModelByCache(int U_ID)
        //{

        //    string CacheKey = "Vote_UserModel-" + U_ID;
        //    object objModel = LTP.Common.DataCache.GetCache(CacheKey);
        //    if (objModel == null)
        //    {
        //        try
        //        {
        //            objModel = dal.GetModel(U_ID);
        //            if (objModel != null)
        //            {
        //                int ModelCache = LTP.Common.ConfigHelper.GetConfigInt("ModelCache");
        //                LTP.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
        //            }
        //        }
        //        catch { }
        //    }
        //    return (Charmmax.Model.Vote_User)objModel;
        //}

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Charmmax.Model.Vote_User> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            List<Charmmax.Model.Vote_User> modelList = new List<Charmmax.Model.Vote_User>();
            int rowsCount = ds.Tables[0].Rows.Count;
            if (rowsCount > 0)
            {
                Charmmax.Model.Vote_User model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Charmmax.Model.Vote_User();
                    if (ds.Tables[0].Rows[n]["U_ID"].ToString() != "")
                    {
                        model.U_ID = int.Parse(ds.Tables[0].Rows[n]["U_ID"].ToString());
                    }
                    model.U_User = ds.Tables[0].Rows[n]["U_User"].ToString();
                    model.U_PassWord = ds.Tables[0].Rows[n]["U_PassWord"].ToString();
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        //{
        //return dal.GetList(PageSize,PageIndex,strWhere);
        //}

        #endregion  成员方法
    }
}

